<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateGoodsTable extends Migration
{
    public function up()
    {
        Schema::create('goods', function (Blueprint $table) {
            $table->bigIncrements('id')->unsigned();
            $table->bigInteger('commodity_id')->unsigned()->comment('商品id');
            $table->string('commodity_name',10)->comment('商品名称');
            $table->bigInteger('commodity_price')->unsigned()->comment('价格');
            $table->bigInteger('commodity_number')->unsigned()->comment('数量');
            $table->bigInteger('brand_id')->unsigned()->comment('关联品牌表');
            $table->foreign('brand_id')->references('id')->on('brand');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('goods', function ($table) {
            $table->dropForeign(['brand_id']);
        });
        Schema::dropIfExists('goods');
    }
}
